<%inherit file="/admin/node.html"/>

<%block name="innav">
<li><a href="${ reverse_url('admin:node') }">${ _("Node") }</a></li>
</%block>

<%block name="main">

<div>
  % if nodes:
  <table class="table table-striped table-bordered">
    <thead>
      <tr>
        <th>${ _("ID") }</th>
        <th>${ _("Hostname") }</th>
        <th>${ _("IP") }</th>
        <th>${ _("Status") }</th>
        <th>${ _("CPU") }</th>
        <th>${ _("Memory") }</th>
        <th>${ _("VCPU") }</th>
        <th>${ _("VMemory") }</th>
        <th>${ _("Is enabled ?") }</th>
        <th>${ _("Instances") }</th>
      </tr>
    </thead>
    <tbody>
      % for n in nodes:
      <tr>
        <td>${ n.id }</td>
        <td><a href="${ reverse_url('admin:node') }?id=${ n.id }">${ n.hostname }</a></td>
        <td>${ n.ip }</td>
        <td><img src="${ theme_url('icons/NodeStatus/%s.png' % n.status) }" alt="${ n.status }"/></td>
        <td>${ n.cpus }</td>
        <td>${ n.memory_human }</td>
        <td>${ n.vcpus }</td>
        <td>${ n.vmemory_human }</td>
        <td><input type="checkbox"
           % if n.isenable:
           checked="checked"
           % endif
           onclick="simpleToggleCheckbox( this, '${ reverse_url('node:isenable', n.id) }', '#isenable-notify')" />
        </td>
        <td>
      % if n.instances_sum:
      <a href="${ reverse_url('admin:instance') }?node=${ n.id }" target="_blank">${ n.instances_sum }</a>
      /
      <a href="${ reverse_url('admin:instance') }?node=${ n.id }&status=running" target="_blank">${ n.instances_running_sum }</a>
      % endif
    </td>
      </tr>
      % endfor
    </tbody>
  </table>
  % else:
  <div class="hero-unit">
    <p class="text-warning">Have not found any nodes. Please register first!</p>
  </div>
  % endif
</div>

<div id="isenable-notify" style="display:none">
  <div id="basic-template">
    <a class="ui-notify-cross ui-notify-close" href="#">x</a>
    <p>${ _("Toggle Node isenable status Success") }</p>
  </div>
  <div id="error-template">
    <a class="ui-notify-cross ui-notify-close" href="#">x</a>
    <h1>${ _("Toggle Node isenable status Failed") }</h1>
    <p>#{text}</p>
  </div>
</div>

</%block>
